home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Documents / NeXTAnswers / objc.594 < prev    next >
Text File  |  1992-02-06  |  2KB  |  52 lines

  1. {\rtf0\ansi{\fonttbl\f3\fnil Times-Roman;\f0\fmodern Courier;\f1\fswiss Helvetica;}
  2. \paperw11760
  3. \paperh7200
  4. \margl120
  5. \margr120
  6. {\colortbl\red0\green0\blue0;}
  7. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f3\b0\i0\ul0\fs28 CC preprocessor compiling UNIX utilities\
  8.     \
  9. Q:  The following code snippet is excerpted from a Bourne shell script which attempts to determine how to invoke the C preprocessor on any given UNIX platform.  The script will create a file called testcpp.c and run the C preprocessor on that file redirecting the output to testcpp.out.  When I run this script on the NeXT it incorrectly inserts a space in the output file "
  10. \f0\fs24 abc +xyz
  11. \f3\fs28 ".  This causes the test which confirms "cc -E" as the correct invokation to fail.  Is this a bug in your C preprocessor?\
  12. \
  13.  
  14. \i     \
  15.  
  16. \f0\i0\fs24 : see how we invoke the C preprocessor\
  17. echo " "\
  18. echo "Checking to see how your C preprocessor is invoked..."\
  19. cat <<'EOT' >testcpp.c\
  20. #define ABC abc\
  21. #define XYZ xyz\
  22. ABC+XYZ\
  23. EOT\
  24. echo 'Maybe "cc -E" will work...'\
  25. cc -E testcpp.c >testcpp.out 2>&1\
  26. if $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then\
  27.     echo "Yup, it does."\
  28.     cpp='cc -E'\
  29. else\
  30.     echo 'Nope...maybe "cc -P" will work...'\
  31.     cc -P testcpp.c >testcpp.out 2>&1\
  32.     if $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then\
  33.     echo "Yup, that does."\
  34.  
  35. \f3\fs28 \
  36. \
  37. A:  The space inserted before the "+xyz" follows the behavior specified by ANSI C.  If you want the old behavior of standard UNIX compilers, use the 
  38. \f0\fs24 -traditional
  39. \f3\fs28  flag.  The man page on cc(1) shows a large number of useful compiler flags in addition to 
  40. \f0\fs24 -traditional
  41. \f3\fs28 .  The flags 
  42. \f0\fs24 -bsd
  43. \f3\fs28  and 
  44. \f0\fs24 -fwritable-strings
  45. \f3\fs28  may also be needed when compiling old UNIX programs.\
  46. \
  47. \
  48. Valid for 2.0\
  49. QA594                \
  50. \
  51.  
  52.